home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1991-11-24 | 2.5 KB | 66 lines | [ TEXT/KEEN]
#$Chain: call a bunch of little hAWK programs to repeatedly #filter and massage some text into the required shape. Rather #like piping. Any program which requires no libraries or #variables and sends its output to stdout is callable here. #Programs are executed from left to right (in the order typed in). #For example, entering # notIndented firstField #will execute the program "notIndented" followed by #the program "firstField" - stripping away all lines that #are indented, then trimming down to just the first field #on each line (use for example on the results of $XRef #to generate a bare list of names with no types or references). #Usage: #There are two practical ways to provide input to this program; either #take input from "Front text selection" or "All of front text", or #set input to the specific file "$tempStdOut" -- the former is #more flexible, the latter means you don't have to bring any specific #file to the front before running this program. #Run, and when the dialog appears type in the names of the programs #you wish to be run on the text in tempStdOut (the first name you type #is the first program run). The final result will be in stdout, and will #be shown to you if you leave "Show stdout" selected. #Ideally the little programs that this "dispatcher" calls should #free up memory when possible, since the "hAWK" call does not (yet) #do so automatically. See for example "asort". #Little programs supplied: asort, nsort, dsort, rasort, rnsort, rdsort, #reverse, notIndented, firstField, secondField, thirdField, numberLines. BEGIN { if ((answer = prompt("Enter any of asort, nsort, dsort, rasort, rnsort, rdsort, reverse, notIndented, firstField, secondField, thirdField, numberLines -- exec order is left to right.")) != "") { n = split(answer, progs) for (i = 1; i <= n; ++i) { #Note since "hAWK" is being repeatedly called, some care #must be taken to ensure that the array of arguments passed #along contains no spurious entries. if (notFirst == 1) { for (w in argv) delete argv[w]; x = 0; } progFile = STDPATH "Drag_on Modules:hAWK programs:" progs[i] argv[x++] = "hAWK" argv[x++] = "-f" progFile argv[x++] = "--" #Input for the first program is whatever was supplied to #this program; for subsequent programs, the appropriate #input is in "$tempStdOut". if (notFirst != 1) { for (j = 1; j < ARGC; ++j) argv[x++] = ARGV[j] } else argv[x++] = STDPATH "$tempStdOut" notFirst = 1; hAWK(argv) } } }